import * as qs from "qs";
import {
    AppointmentComment,
    BocoPage,
    Depart,
    IfilterParam,
    RestPage
} from "../type/CommonData";
import service from "./Service";
import { DoctorData, DoctorFilter } from "../type/DoctorData";
import { HospitalFilter, HospitalInfo } from "../type/HospitalData";
import {Verify,IReservationRecord} from "../type/UserInfoData";
/**
 * 获取新闻列表
 */
export  function getNews(params?:any){
  return service.get("/news",{params})
}
/**
 * 获取信息列表
 */
export  function getInfo(params?:any){
  return service.get("/news?firstType=信息公开",{params})
}

/**
 * 获取医院列表
 */
export function getHos(params?:any) {
    return service.get("/portalHospitals",{params})
}

/**
 * 模拟登陆
 */
export function LogIn(param:any) {
    return service.post("/loginByPhonePwd",qs.stringify(param))
}
/**
 * 获取医生列表
 */
export function getDocs(params:any) {
    return service.get("/portalDoctors",{params})
}
/**
 * 获取用户信息
 */
export function getUserInfo() {
    return service.get("/healthFile?user")
}

export function getUserMsg() {
    return service.get("/user/getMessageLog")
}
/**
 * 获取用户信息
 */
export function postVerify(data:Verify) {
    return service.post("/verifies",data)
}
/**
 * 获取医院列表
 */
export function getHealthList(param: IfilterParam) {
    let hospital: HospitalFilter;
    if (param.filterOne !== null) {
        const fliter: any = param.filterOne;
        hospital = {
            level: fliter.slice(0, 2),
            category: fliter.slice(2, 4),
            name: param.searchParam
        };
    } else {
        hospital = {
            name: param.searchParam
        };
    }
    return service.get<BocoPage<HospitalInfo>>("/hospitals", {
        params: hospital
    });
}
/**
 * 获取一个医院信息
 */
export function getHealthOne(id: string) {
    return service.get<BocoPage<HospitalInfo>>("/hospitals", { params: { id } });
}
/**
 * 通过条件获取医生
 */
export function getDoctorList(param: IfilterParam) {
    const doctor: DoctorFilter = {
        level: param.filterOne,
        category: param.filterTwo,
        name: param.searchParam
    };
    return service.get<BocoPage<DoctorData>>("doctors", { params: doctor });
}
/**
 * 获取单个医生
 */
export function getDoctorOne(params: any) {
    return service.get<BocoPage<DoctorData>>("doctors", { params });
}
/**
 * 获取就诊记录
 */
export function getRecordList(params: any) {
    return service.get<RestPage<IReservationRecord>>("/advanceRecords/query", {
        params
    });
}

/**
 * 获取部门列表
 */
export function getDepartList(params: any) {
    return service.get<BocoPage<Depart>>("/departs", { params });
}
/**
 * 获取医生评价或获取医院评价
 */
export function getDoctorOrHospitalComment(params: any) {
    return service.get<BocoPage<AppointmentComment>>("/commentEntities", {
        params
    });
}
